import type { PageParams } from '@/types/common'
import type { ChangeRoleParams, Role, RoleData, RoleDetail, RoleParams, RoleUserData, UpdateRole } from '@/types/system'
import {request} from '@/utils/reuqest'

/**
 * 获取角色列表
 * @returns
 */
export const getRoleListAPI = () => {
  return request<Role[]>('/park/sys/role')
}
//获取tree权限列表
export const getTreeListAPI=() => {
  return request<RoleData[]>('/park/sys/permision/all/tree')
}
//查询当前角色的获取内容
export const getRoleDetailAPI = (id: number) => {
  return request<RoleDetail>(`/park/sys/role/${id}`)
}
// /**
//  * 获取角色成员列表
//  * @returns
//  */
// export const getRoleUserAPI = (roleId: number) => {
//   return request<RoleUserData>(`/park/sys/roleUser/${roleId}`)
// }
/**
 * 获取角色成员列表
 * @param roleId 角色id
 * @param params 分页参数
 * @returns 
 */
export const getRoleUserAPI = (roleId: number, params?: PageParams) => {
  return request<RoleUserData>(`/park/sys/roleUser/${roleId}`, 'GET', params)
}

//添加用户
export const createRoleUserAPI =(data: RoleParams)=>{
  return request<RoleUserData>('/park/sys/role', 'POST', data)
}

//修改用户 下载 get请求
export const updateRoleGetAPI =(id:number)=>{
  return request<UpdateRole>(`/park/sys/role/${id}`, 'GET')
}

//修改用户 上传 put请求
export const updateRoleUserAPI =(data: ChangeRoleParams)=>{
  return request<UpdateRole>('/park/sys/role', 'PUT', data)
}